/*
 * Copyright (C) Hisilicon Technologies Co., Ltd. 2012-2019. All rights reserved.
 * Description: Function of sample_awb_ext_config.h
 * Author: ISP SW
 * Create: 2012/06/28
 */

#ifndef __HI_AWB_EXT_CONFIG_H__
#define __HI_AWB_EXT_CONFIG_H__

#include "isp_vreg.h"

#ifdef __cplusplus
#if __cplusplus
extern "C" {
#endif
#endif /* End of #ifdef __cplusplus */

/*
 * ------------------------------------------------------------------------------
 *          these two entity illustrate how to use a ext register
 *
 * 1. Awb Mode
 * 2. Detected color temperature
 *
 * ------------------------------------------------------------------------------
 */
// ------------------------------------------------------------------------------ //
// Register: hi_ext_system_WB_type
// ------------------------------------------------------------------------------ //
// white balance type, 0 auto, 1 manual
// ------------------------------------------------------------------------------ //
#define HI_EXT_SYSTEM_WB_TYPE_DEFAULT         0x0
#define HI_EXT_SYSTEM_WB_TYPE_DATASIZE        1

// args: data (2-bit)
static __inline HI_VOID hi_ext_system_wb_type_write(HI_U8 id, HI_U8 data)
{
    iowr_8direct((awb_lib_vreg_base(id)), data);
}
static __inline HI_U8 hi_ext_system_wb_type_read(HI_U8 id)
{
    return (iord_8direct(awb_lib_vreg_base(id)) & 0x1);
}

// ------------------------------------------------------------------------------ //
// Register: hi_ext_system_wb_detect_temp
// ------------------------------------------------------------------------------ //
// the detected color temperature
// ------------------------------------------------------------------------------ //
#define HI_EXT_SYSTEM_WB_DETECT_TEMP_DEFAULT  5000
#define HI_EXT_SYSTEM_WB_DETECT_TEMP_DATASIZE 16

// args: data (16-bit)
static __inline HI_VOID hi_ext_system_wb_detect_temp_write(HI_U8 id, HI_U16 data)
{
    iowr_16direct((awb_lib_vreg_base(id) + 0x2), data);
}

static __inline HI_U16 hi_ext_system_wb_detect_temp_read(HI_U8 id)
{
    return iord_16direct(awb_lib_vreg_base(id) + 0x2);
}

#ifdef __cplusplus
#if __cplusplus
}
#endif
#endif /* End of #ifdef __cplusplus */

#endif
